//
//  CGQduankouDetailTableViewCell.swift
//  SheYangBigData
//
//  Created by 叁拾叁 on 2021/5/11.
//  Copyright © 2021 叁拾叁. All rights reserved.
//

import UIKit

class CGQduankouDetailTableViewCell: SYBaseCell {
    
    var bgView: UIView = {
        let v = UIView()
        v.backgroundColor = .white
        return v
    }()
    let tiplab: UILabel = {
        let v = UILabel()
        v.text = "端口开启"
        v.font = 15.autoBoldFontSize()
        v.textColor = UIColor(hex: 0x333333)
        return v
    }()
    var lView: UIView = {
        let v = UIView()
        v.backgroundColor = UIColor(hex: 0xF0F0F0)
        return v
    }()
    
    
    
    
    let xiangmu: CGQlixianView = {
        let v = CGQlixianView()
        v.title.text = "端口名称："
        v.num.text = "龙吃鲫鱼"
        return v
    }()
    
    let shebei: CGQlixianView = {
        let v = CGQlixianView()
        v.title.text = "端口状态："
        v.num.text = "二氧化碳"
        return v
    }()
    let shijian: CGQlixianView = {
        let v = CGQlixianView()
        v.title.text = "开启时间："
        v.num.text = "2021-04-19"
        return v
    }()
    let duankouhao: CGQlixianView = {
        let v = CGQlixianView()
        v.title.text = "端口号："
        
        v.num.text = "南京六合龙池鲫鱼项目南京六合龙池鲫鱼项目南京六合龙池鲫鱼项目二氧化碳传感器已经离线，请立即处理"
        return v
    }()
    let xieyi: CGQlixianView = {
        let v = CGQlixianView()
        v.title.text = "解析协议："
        
        v.num.text = "南京六合龙池鲫鱼项目南京六合龙池鲫鱼项目南京六合龙池鲫鱼项目二氧化碳传感器已经离线，请立即处理"
        return v
    }()
    let beizhu: CGQlixianView = {
        let v = CGQlixianView()
        v.title.text = "备注："
        
        v.num.text = "南京六合龙池鲫鱼项目南京六合龙池鲫鱼项目南京六合龙池鲫鱼项目二氧化碳传感器已经离线，请立即处理"
        return v
    }()
    
    public func configureMessageView(model:NSMessageRecordsModel,type: String){
        tiplab.text  = model.title
        xiangmu.num.text = model.portName
        shijian.num.text = model.createDate
        duankouhao.num.text = model.params
        xieyi.num.text = model.protocolName
        beizhu.num.text = model.remarks ?? "暂无内容"
        
        if type == "3" {
            shebei.num.text = "开启"
            shebei.num.textColor = UIColor(hex: 0x08D988)
            shijian.title.text = "开启时间："
            
        }else{
            shijian.title.text = "关闭时间："
            shebei.num.text = "关闭"
            shebei.num.textColor = UIColor(hex: 0xFF5D5C)
   
        }
        
     
        
        
    }
    
    
    override func initViews() {
    
        addSubview(bgView)
        bgView.addSubview(tiplab)
        bgView.addSubview(lView)
        bgView.addSubview(xiangmu)
        bgView.addSubview(shebei)
        bgView.addSubview(shijian)
        bgView.addSubview(duankouhao)
        bgView.addSubview(xieyi)
        bgView.addSubview(beizhu)
        
        bgView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(10.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(10))
            make.right.equalToSuperview().offset(autoWidth(-10))
            make.bottom.equalToSuperview()
        }
        tiplab.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(19.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(12))
            make.right.equalToSuperview().offset(autoWidth(-12))
        }
        lView.snp.makeConstraints { (make) in
            make.top.equalTo(tiplab.snp.bottom).offset(14.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(0))
            make.right.equalToSuperview().offset(autoWidth(0))
            make.height.equalTo(0.5)
        }
        
        xiangmu.snp.makeConstraints { (make) in
            make.top.equalTo(lView.snp.bottom).offset(17.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(12))
            make.right.equalToSuperview().offset(autoWidth(-15))
        }
        shebei.snp.makeConstraints { (make) in
            make.top.equalTo(xiangmu.snp.bottom).offset(17.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(12))
            make.right.equalToSuperview().offset(autoWidth(-15))
        }
        shijian.snp.makeConstraints { (make) in
            make.top.equalTo(shebei.snp.bottom).offset(17.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(12))
            make.right.equalToSuperview().offset(autoWidth(-15))
        }
        duankouhao.snp.makeConstraints { (make) in
            make.top.equalTo(shijian.snp.bottom).offset(17.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(12))
            make.right.equalToSuperview().offset(autoWidth(-15))
        }
        xieyi.snp.makeConstraints { (make) in
            make.top.equalTo(duankouhao.snp.bottom).offset(17.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(12))
            make.right.equalToSuperview().offset(autoWidth(-15))
        }
        beizhu.snp.makeConstraints { (make) in
            make.top.equalTo(xieyi.snp.bottom).offset(17.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(12))
            make.right.equalToSuperview().offset(autoWidth(-15))
            make.bottom.equalToSuperview().offset(autoWidth(-17))
        }

    }


}
